<?php
namespace Admin\Controller;
use Think\Controller;
use Admin\Common\Api\UserApi;
use Admin\Common\POMVIPClient;
class GuideController extends BaseController {
    private $adminUser = null;
    public function _initialize(){
    	parent::_initialize();
    	$this->adminUser = new UserApi();

    }
	//获取后台管理员的信息
    public function index(){
      
   $counts = $where = array();
      //获取总下单数/API下单数
      $counts['sum_order_count']  = D('order_info')->where('isbigorder = 0')->count();
    
        //身份证信息不完整的数量
      // $where['isbigorder'] = 0;
   
      $where= 'isbigorder = 0 and  !(idcard  is not null and idcard_syskey  is not null) ';
      $counts['no_idcard_order_count']  = D('order_info')->where($where)->count();
      //未发货总数
      $counts['no_delivery_order_count']  = D('delivery_info')->where('status =0')->count();
      //总商品数量
      $counts['goods_purchase_count']  = D('goods')->where('is_deleted = 0')->count();
      //未完成预订单数量
      $counts['no_directional_count']  = D('order_info')->where('isbigorder = 0 and pack_status = 0')->count();
// print_r($counts);exit;



      //查询仓库库存少于num的商品，查询limit条。两个变量 在conf中配置
      $limit = C('DISPLAY_GOODS_NUMBER');     //显示危险库存商品几条
      $quantity =C('MINIMUM_SYOCK_NUMBER');      //危险库存数量
      $goods_list = M('goods')
                  ->alias('a')
                  ->field('a.goods_sn,b.quantity,b.salenumber')
                  ->join('inner join vip_inventory b on a.goods_sn = b.goods_sn')
                  ->where('b.quantity-b.salenumber <='.$quantity .'  and a.is_deleted = 0')
                  ->order('(quantity -salenumber) ASC')
                  ->limit($limit)
                  ->select();
      
     // echo M("goods")->getLastSql(); exit;
      $this->assign('goods_list',$goods_list);  

          $balance_message = '';
          $POMVIPClient = new POMVIPClient();
           if(!$POMVIPClient->checkUserMoney()){
               $balance_message='您的余额不足请进行充值';
           }     
          $this->assign('balance_message',$balance_message);
          $this->assign('count',$counts);
          $this->display();
        }

   
}
